<template>
	<view class="card store" :style="{ backgroundImage: `url(${store?.cover_url})` }" @click="handleClick">
		<view class="content">
			<view class="header">
				<view class="store-info">
					<image class="store-logo" :src="store?.logo_url" mode="aspectFill" />
					<view>
						<view class="store-name">{{ store?.name }}</view>
						<view class="store-wrap">
							<image
								v-if="store?.self_employed"
								:src="`${imgBaseUrl}self_employed.png`"
								class="self_employed"
							/>
							<text class="intro">{{ store?.intro }}</text>
						</view>
					</view>
				</view>
				<view class="btn">进店逛逛</view>
			</view>
			<view class="footer">
				<view class="icons">
					<image class="icon" :src="`${imgBaseUrl}shop-icon.png`" />
					<text class="text">全部商品</text>
				</view>
				<view class="icons">
					<image class="icon" :src="`${imgBaseUrl}contact-icon.png`" />
					<text class="text">联系商家</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
interface Store {
	id: string
	logo_url: string
	cover_url: string
	name: string
	self_employed: boolean
	intro: string
}

interface StoreProps {
	store: Store
}

defineProps<StoreProps>()

const imgBaseUrl = inject("imgBaseUrl")

const handleClick = () => uni.showToast({ icon: "none", title: "暂不支持跳转门店" })
</script>

<style lang="scss" scoped>
@import "../ticket/index.scss";

.store {
	position: relative;
	padding-bottom: 28rpx;
	background-repeat: no-repeat;
	background-size: cover;

	&::before {
		content: "";
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.6);
		border-radius: 16rpx;
		z-index: 1;
	}

	.content {
		position: relative;
		z-index: 2;
	}

	.header {
		display: flex;
		justify-content: space-between;
		padding-bottom: 32rpx;
		border-bottom-width: 1rpx;
		border-bottom-style: solid;
		border-bottom-color: rgba(255, 255, 255, 0.2);

		.store-info {
			display: flex;
			align-items: center;

			.store-logo {
				width: 104rpx;
				height: 104rpx;
				border-radius: 15rpx;
				margin-right: 20rpx;
				background-color: #fff;
			}

			.store-name {
				font-weight: 500;
				font-size: 32rpx;
				color: #fff;
				line-height: 44rpx;
				margin-bottom: 8rpx;
			}

			.store-wrap {
				display: inline-flex;
				align-items: center;
			}

			.self_employed {
				width: 56rpx;
				height: 32rpx;
				margin-right: 8rpx;
			}

			.intro {
				font-size: 24rpx;
				color: rgba(255, 255, 255, 0.7);
				line-height: 36rpx;
			}
		}

		.btn {
			width: 144rpx;
			height: 48rpx;
			background: #fee038;
			border-radius: 24rpx;
			font-weight: 500;
			font-size: 24rpx;
			color: #1d2129;
			line-height: 48rpx;
			text-align: center;
		}
	}

	.footer {
		display: flex;
		justify-content: space-around;
		align-items: center;
		padding-top: 30rpx;

		.icons {
			display: inline-flex;
			align-items: center;

			&:first-child {
				padding-right: 110rpx;
				border-right: 1rpx solid #fff;
				border-right-color: rgba(255, 255, 255, 0.2);
			}

			.icon {
				width: 36rpx;
				height: 36rpx;
			}

			.text {
				margin-left: 8rpx;
				font-size: 28rpx;
				color: #fff;
				line-height: 40rpx;
			}
		}
	}
}
</style>
